package Assignment;

import javax.sound.midi.SysexMessage;
import java.util.Scanner;

//由键盘录入一个字符串，统计字符串中英文字母和数字分别有多少个。比如：Hello12345World中字母：10个，数字：5个。
public class Test3 {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入字符串：");
        String str = scanner.next();

        System.out.println(Find(str));
    }

    public static String Find(String str){
        int alphabetCount = 0;
        int nuberCount = 0;

        for (int i = 0; i < str.length(); i++) {
            char temp = str.charAt(i);

            if (temp>='a'&&temp<='z'||temp>='A'&&temp<='Z'){
                alphabetCount++;
            } else if (temp>='0'&&temp<='9') {
                nuberCount++;
            }
        }
        return "数字："+nuberCount+",字母："+alphabetCount;
    }
}
